<?php
class Default_Model_DbTable_Contact extends Zend_Db_Table_Abstract {
	protected $_name = 'contact';
	public function addContact($email, $address, $phone_number, $title, $content, $create_date, $status) {
		$data = array (
				'EMAIL' => $email,
				'ADDRESS' => $address,
				'PHONE_NUMBER' => $phone_number,
				'TITLE' => $title,
				'CONTENT' => $content,
				'CREATE_DATE' => $create_date,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function removeContact($contact_id) {
		return $this->delete ( "ID = $contact_id" );
	}
	public function updateContact($contact_id, $email, $address, $phone_number, $title, $content, $create_date, $status) {
		$data = array (
				'EMAIL' => $email,
				'ADDRESS' => $address,
				'PHONE_NUMBER' => $phone_number,
				'TITLE' => $title,
				'CONTENT' => $content,
				'CREATE_DATE' => $create_date,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $contact_id" );
	}
	public function updateStatus($contact_id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $contact_id" );
	}
	public function getAllContact() {
		return $this->fetchAll ( "STATUS = 1" )->toArray ();
	}
	public function viewContactIsPeding($status) {
		return $this->fetchAll("STATUS = $status");
	}
	public function viewContactIsDoning($status) {
		return $this->fetchAll("STATUS = $status");
		
	}
	public function getContactByEmail($email) {
		return $this->fetchAll("EMAIL = '$email'");
		
	}
	public function getContactByStatus($status) {
		return $this->fetchAll("STATUS = $status");
	
	}
}

